package com.goodfox.web.generic.area.entity;

import java.io.Serializable;
import java.util.Set;

import com.goodfox.web.generic.provide.annotation.DbEntity;
import com.goodfox.web.generic.provide.annotation.DbField;

@DbEntity(comment="地区",table="DSYS_AREA",remark="（国家、省、市）")
public class Area implements Serializable,Comparable<Area> {

	@DbField(comment="实例化UID",meaning=false)
	private static final long serialVersionUID = -2794045397456236075L;
	
	@DbField(comment="地区ID",column="AREA_ID",pk=true,export=false,javaType="String",dataType="VARCHAR2",required=true,maxLength=50)
	private String areaId;

	@DbField(comment="上级地区ID",column="AREA_ID_PARENT",javaType="String",dataType="VARCHAR2",maxLength=50)
	private String areaIdParent;

	@DbField(comment="地区名称",column="AREA_NAME",javaType="String",dataType="VARCHAR2",required=true,maxLength=100)
	private String areaName;

	@DbField(comment="地区编码",column="AREA_CODE",javaType="String",dataType="VARCHAR2",maxLength=50)
	private String areaCode;

	@DbField(comment="地区区号",column="AREA_NUMBER",javaType="String",dataType="VARCHAR2",maxLength=10)
	private String areaNumber;

	@DbField(comment="地区邮编",column="AREA_ZIP",javaType="String",dataType="VARCHAR2",maxLength=10)
	private String areaZip;

	@DbField(comment="地区排序",column="AREA_SORT",javaType="Long",dataType="NUMBER",maxLength=4)
	private Long areaSort;

	@DbField(comment="地区层级",column="AREA_GRADE",javaType="Long",dataType="NUMBER",maxLength=4)
	private Long areaGrade;

	@DbField(comment="所属上级",column="AREA_NAME_PARENT",direct=false)
	private String areaNameParent;

	@DbField(comment="子机构数量",column="SUB_COUNT",direct=false)
	private Long subCount;
	
	@DbField(comment="所属上级层级",column="AREA_GRADE_PARENT",javaType="Long",dataType="NUMBER",direct=false)
	private Long areaGradeParent;
	
	@DbField(comment="子地区列表",export=false,direct=false)
	private Set<Area> realSubAreaSet;

	@DbField(comment="子地区数量",export=false,direct=false)
	private Long realSubAreaCount;

	public String getAreaId() {
		return areaId;
	}

	public void setAreaId(String areaId) {
		this.areaId = areaId;
	}

	public String getAreaIdParent() {
		return areaIdParent;
	}

	public void setAreaIdParent(String areaIdParent) {
		this.areaIdParent = areaIdParent;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	public String getAreaCode() {
		return areaCode;
	}

	public void setAreaCode(String areaCode) {
		this.areaCode = areaCode;
	}

	public String getAreaNumber() {
		return areaNumber;
	}

	public void setAreaNumber(String areaNumber) {
		this.areaNumber = areaNumber;
	}

	public String getAreaZip() {
		return areaZip;
	}

	public void setAreaZip(String areaZip) {
		this.areaZip = areaZip;
	}

	public Long getAreaSort() {
		return areaSort;
	}

	public void setAreaSort(Long areaSort) {
		this.areaSort = areaSort;
	}

	public Long getAreaGrade() {
		return areaGrade;
	}

	public void setAreaGrade(Long areaGrade) {
		this.areaGrade = areaGrade;
	}

	public String getAreaNameParent() {
		return areaNameParent;
	}

	public void setAreaNameParent(String areaNameParent) {
		this.areaNameParent = areaNameParent;
	}

	public Long getSubCount() {
		return subCount;
	}

	public void setSubCount(Long subCount) {
		this.subCount = subCount;
	}

	public Long getAreaGradeParent() {
		return areaGradeParent;
	}

	public void setAreaGradeParent(Long areaGradeParent) {
		this.areaGradeParent = areaGradeParent;
	}
	
	public Set<Area> getRealSubAreaSet() {
		return realSubAreaSet;
	}

	public void setRealSubAreaSet(Set<Area> realSubAreaSet) {
		this.realSubAreaSet = realSubAreaSet;
	}

	public Long getRealSubAreaCount() {
		return realSubAreaCount;
	}

	public void setRealSubAreaCount(Long realSubAreaCount) {
		this.realSubAreaCount = realSubAreaCount;
	}

	/**
	 * 覆盖比较方法，排序用
	 * @param resources
	 * @return
	 */
	@Override
	public int compareTo(Area area) {
		return Integer.parseInt(String.valueOf((getAreaSort()-area.getAreaSort())));
	}
	
}
